package javapop.framework.parser.expr;

public abstract class DefaultExprNode implements ExprNode {
	@Override
	public boolean isInfix() {
		//return false;
		return (this instanceof InfixNode); // ca evite plein d'erreur inutile quand on fait les classes specialise à notre archi
	}
	
	@Override
	public InfixNode asInfix() {
		if(!(this instanceof InfixNode)) {
			throw new Error("Not an infix node");
		}
		return (InfixNode) this;
	}

	@Override
	public boolean isPrefix() {
		//return false;
		return (this instanceof PrefixNode); 
	}
	
	@Override
	public PrefixNode asPrefix() {
		if(!(this instanceof PrefixNode)) {
			throw new Error("Not a prefix node");
		}
		return (PrefixNode) this;
	}

	@Override
	public boolean isPostfix() {
		//return false;
		return (this instanceof PostfixNode);
	}
	
	@Override
	public PostfixNode asPostfix() {
		if(!(this instanceof PostfixNode)) {
			throw new Error("Not a postfix node");
		}
		return (PostfixNode) this;
	}

	@Override
	public boolean isOperand() {
		//return false;
		return (this instanceof OperandNode);
	}

	@Override
	public OperandNode asOperand() {
		if(!(this instanceof OperandNode)) {
			throw new Error("Not an operand node");
		}
		return (OperandNode) this;
	}
	
	@Override
	public final String toString() {
		return getDescription();
	}

}
